package cn.wd.user.service.impl;


import cn.wd.user.domain.entity.ReportTable;
import cn.wd.user.domain.mapper.ReportTableMapper;
import cn.wd.user.page.PageResult;
import cn.wd.user.qo.QueryObject;
import cn.wd.user.qo.ReportTableQueryObject;
import cn.wd.user.service.IReportTableService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReportTableServiceImpl extends ServiceImpl<ReportTableMapper, ReportTable> implements IReportTableService {

    private final ReportTableMapper mapper;

    public ReportTableServiceImpl(ReportTableMapper mapper) {
        this.mapper = mapper;
    }

    // @Override
    // public void save(ReportTable obj) {
    //     mapper.insert(obj);
    // }
    //
    // @Override
    // public void deleteById(Long id) {
    //     mapper.deleteByPrimaryKey(id);
    // }
    //
    // @Override
    // public void updateById(ReportTable obj) {
    //     mapper.updateByPrimaryKey(obj);
    // }
    //
    // @Override
    // public ReportTable selectById(Long id) {
    //     return mapper.selectByPrimaryKey(id);
    // }
    //
    // @Override
    // public List<ReportTable> selectAll() {
    //     return mapper.selectAll();
    // }

    @Override
    public Page<ReportTable> listReportTablePage(ReportTableQueryObject qo) {
        qo.computePageCount();
        Long count = mapper.selectForCount(qo);
        if (count == 0) {
            return new Page<>(qo.getPageNum(), qo.getPageSize());
        }
        List<ReportTable> list = mapper.selectForList(qo);

        return new Page<ReportTable>(qo.getPageNum(), qo.getPageSize(), count).setRecords(list);
    }
}
